#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;

int GetMonthDay(int year, int month)
{
    int monthArray[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30,31 };

    if (month == 2 && ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)))
        return 29;

    return monthArray[month];
}

#include <iostream>
using namespace std;

int GetMonthDay(int year, int month)
{
    int monthArray[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30,31 };

    if (month == 2 && ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)))
        return 29;

    return monthArray[month];
}

int main()
{
    int year, day;
    while ((scanf("%d %d", &year, &day) != EOF))
    {
        int month = 1, dday = 0;
        while (day > 365)
        {
            if (day > 366 && ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)))
            {
                year++;
                day -= 366;
            }
            else if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
            {
                year++;
                day -= 365;
            }
        }
        for (int i = 1; i <= 12; i++)
        {
            if (day / GetMonthDay(year, i) != 0)
            {
                if (day % GetMonthDay(year, i) == 0 && day == GetMonthDay(year, i))
                {
                    dday += day;
                    break;
                }
                month++;
                day -= GetMonthDay(year, i);
            }
            else
            {
                if (day == 0)
                {
                    dday += GetMonthDay(year, i);
                    break;
                }
                dday += day;
                break;
            }
        }
        printf("%d-%02d-%02d\n", year, month, dday);
    }
}